package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResPicture;
import com.hmkj.entity.ErspSysUser;

public class ErspSysUserDao extends JActiveTable {
	public ErspSysUserDao() {
		this.setDBTableName("ersp_res_picture");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("user_identity", "user_identity", ActiveField.ftString, 200));
		AddField(new JActiveField("user_passhash", "user_passhash", ActiveField.ftString, 256));
		AddField(new JActiveField("org_id", "org_id", ActiveField.ftString, 36));
		AddField(new JActiveField("user_phone", "user_phone", ActiveField.ftString, 50));
		AddField(new JActiveField("user_status", "user_status", ActiveField.ftString, 4));
		AddField(new JActiveField("user_checked", "user_checked", ActiveField.ftString, 2));
		AddField(new JActiveField("user_checked_resp", "user_checked_resp", ActiveField.ftString, 200));
		AddField(new JActiveField("user_realname", "user_realname", ActiveField.ftString, 50));
		AddField(new JActiveField("user_mailaddr", "user_mailaddr", ActiveField.ftString, 200));
		AddField(new JActiveField("user_idtype", "user_idtype", ActiveField.ftString, 11));
		AddField(new JActiveField("user_cardinfo", "user_cardinfo", ActiveField.ftString, 100));
		AddField(new JActiveField("sys_path", "sys_path", ActiveField.ftString, 500));
		
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
        setDbKeyFields("id");
	}

	public int add(ErspSysUser vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("user_identity", vo.getUser_identity());
		setFieldValue("user_passhash", vo.getUser_passhash());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_phone", vo.getUser_phone());
		setFieldValue("user_status", vo.getUser_status());
		setFieldValue("user_checked", vo.getUser_checked());
		setFieldValue("user_checked_resp", vo.getUser_checked_resp());
		setFieldValue("user_realname", vo.getUser_realname());
		setFieldValue("user_mailaddr", vo.getUser_mailaddr());
		setFieldValue("user_idtype", vo.getUser_idtype());
		setFieldValue("user_cardinfo", vo.getUser_cardinfo());
		setFieldValue("sys_path", vo.getSys_path());
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspSysUser vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("user_identity", vo.getUser_identity());
		setFieldValue("user_passhash", vo.getUser_passhash());
		setFieldValue("org_id", vo.getOrg_id());
		setFieldValue("user_phone", vo.getUser_phone());
		setFieldValue("user_status", vo.getUser_status());
		setFieldValue("user_checked", vo.getUser_checked());
		setFieldValue("user_checked_resp", vo.getUser_checked_resp());
		setFieldValue("user_realname", vo.getUser_realname());
		setFieldValue("user_mailaddr", vo.getUser_mailaddr());
		setFieldValue("user_idtype", vo.getUser_idtype());
		setFieldValue("user_cardinfo", vo.getUser_cardinfo());
		setFieldValue("sys_path", vo.getSys_path());
		return this.getSQL();
	}
}
